<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
</head>
<body>

<script>
    //初始化填入信息
    window.onload = function () {
        getUserSession();
        showAllTheme();
    }

    //从session中获取用户信息
    async function getUserSession() {
        let userBean = await ajaxGet("/user/getUserSession");
        console.log(userBean);
        $("headImg").src = "/html/imgs/" + userBean.headImg + ".jpg";
        $("username").innerHTML = userBean.username;
        $("email").innerHTML = userBean.email;
    }


    async function showAllTheme() {
        let themeList = await ajaxGet("/theme/showAllTheme");
        let str = "<div style='display: flex;justify-content: space-around' class='layui-bg-blue'>";
        str += "<label class=\"layui-form-label\">板块</label>";
        str += "<label class=\"layui-form-label\">板块描述</label>";
        str += "<label class=\"layui-form-label\">贴数量</label>";
        str += "</div>";
        str += "<hr>";
        for (let i = 0; i < themeList.length; i++) {
            str += "<div style='display: flex;justify-content: space-around'>";
            str += `<a href="/html/main/main.html?themeId=${themeList[i].themeId}" class="layui-form-label">${themeList[i].themeName}</a>`;
            str += `<label class="layui-form-label">${themeList[i].describe}</label>`;
            str += `<label class="layui-form-label">${themeList[i].allMCCount}</label>`;
            str += "</div>";
            str += "<hr>";
            str += "<br>";
        }
        $("themeInfo").innerHTML = str;
    }
</script>


<div>
    <ul class="layui-nav" style="display: flex;justify-content: center">
        <li class="layui-nav-item layui-this"><a href="">首页</a></li>
        <li class="layui-nav-item"><a href="">登录</a></li>
        <li class="layui-nav-item "><a href="">注册</a></li>
        <li class="layui-nav-item"><a href="javascript:outAccount()">退出</a></li>
        <li class="layui-nav-item"><a href="">管理</a></li>
        <li class="layui-nav-item"><a href="">风格</a></li>
    </ul>
</div>

<!--登录用户信息-->
<div class="layui-bg-green">
    <div style="text-align: center">
        当前登录用户
    </div>
    <div style="display: flex;justify-content: center">
        <img id="headImg" src="" style="height: 50px;width: 50px">
        <div style="margin:30px">
            <label class="layui-form-label">用户名</label>
            <label class="layui-form-label" id="username"></label>
        </div>
        <div style="margin: 30px">
            <label class="layui-form-label">用户邮箱</label>
            <label class="layui-form-label" id="email"></label>
        </div>
    </div>
</div>
<!--显示各个板块信息-->
<div id="themeInfo" class="layui-bg-gray">


</div>


</body>
</html>